package AudioUDP.Receiver;
// <![CDATA[
// ServerUDP.java
//        exemple d'utilisation des sockets UDP Java Sockets 
//        agent Serveur 
// 

import java.net.*;
import java.io.*;
import java.util.*;

public class ReceiverNotOk extends Thread{ 
    // on utilise des port >1024 pour ne pas avoir de pb de droits
	int PORT_SERVEUR = 2510;
    int TAILLE_MAX_BUFFER=100;
    boolean isOK=true;
	boolean UDPSent=false;
    String reponse;
    DatagramSocket datagramSock = null;
	DatagramPacket outPack = null;
	DatagramPacket inPack = null;
    
    
    
    
    ReceiverNotOk(){
    }
    
    
    public void start(){
    	/***** Former le flux reponse *****/
		while(true){
			try{
				if(UDPSent==false & isOK==false){
					System.out.println("OK3");
					reponse = String.valueOf(isOK);
					System.out.println("OK4");
					//le paquet emit est dimentionné au plus juste
					outPack = new DatagramPacket(reponse.getBytes(),reponse.length(),inPack.getAddress(),inPack.getPort());
					datagramSock.send(outPack);
					UDPSent=true;
					isOK=true;
					System.out.println("STOOOOOOOOP\n\nPLEASE !!");
				}
		}
		catch(Exception e){
			System.out.println("NONKO");
		}
		}
    		
    	
    }
    
    public void setisOK(){
    	isOK=false;
    }
    
}